<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
        PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core"
      xmlns:c="http://java.sun.com/jsp/jstl/core" xmlns:t="http://tms" xml:lang="en" lang="en">

<ui:composition template="../securedTemplate.xhtml">
    <ui:define name="title">#{localizer.localized('WELCOME')}</ui:define>

    <ui:define name="body">
        <ui:decorate template="../navigationTabs.xhtml">
            <ui:param name="currentTab" value="time"/>
            
            <ui:decorate template="tableHeaders.xhtml">
                <h:panelGroup id="timeTable">
                    <h:panelGrid columns="8"
                                 cellspacing="1"
                                 columnClasses="head firstColumn,
                                                    #{timeViewBean.isCurrentTime(timeViewBean.currentWeek.get(0)) ? 'currentColumn' : 'column'},
                                                    #{timeViewBean.isCurrentTime(timeViewBean.currentWeek.get(1)) ? 'currentColumn' : 'column'},
                                                    #{timeViewBean.isCurrentTime(timeViewBean.currentWeek.get(2)) ? 'currentColumn' : 'column'},
                                                    #{timeViewBean.isCurrentTime(timeViewBean.currentWeek.get(3)) ? 'currentColumn' : 'column'},
                                                    #{timeViewBean.isCurrentTime(timeViewBean.currentWeek.get(4)) ? 'currentColumn' : 'column'},
                                                    #{timeViewBean.isCurrentTime(timeViewBean.currentWeek.get(5)) ? 'currentColumn' : 'column'},
                                                    #{timeViewBean.isCurrentTime(timeViewBean.currentWeek.get(6)) ? 'currentColumn' : 'column'}">

                        <h:outputText value="#{localizer.localized('START_TIME')}:&#160;&#160;"/>
                        <c:forEach items="#{timeViewBean.currentWeek}" var="time">
                            <h:outputText value="#{time.startTime}">
                                <f:convertDateTime pattern="HH:mm:ss" timeZone="#{timeViewBean.currentTimeZone}"/>
                            </h:outputText>
                        </c:forEach>

                        <h:outputText value="#{localizer.localized('STOP_TIME')}:&#160;&#160;"/>
                        <c:forEach items="#{timeViewBean.currentWeek}" var="time">
                            <h:outputText value="#{time.stopTime}">
                                <f:convertDateTime pattern="HH:mm:ss" timeZone="#{timeViewBean.currentTimeZone}"/>
                            </h:outputText>
                        </c:forEach>

                        <h:outputText value="#{localizer.localized('TOTAL_TIME')}:&#160;&#160;"/>
                        <c:forEach items="#{timeViewBean.currentWeek}" var="time">
                            <t:totalTime time="#{time}"/>
                        </c:forEach> 
                    </h:panelGrid>
                    <h:panelGrid columns="8"
                                 cellspacing="1"
                                 columnClasses="indicatorColumn, indicatorColumn, indicatorColumn, indicatorColumn, indicatorColumn, indicatorColumn, indicatorColumn, indicatorColumn">
                        <h:panelGroup>&#160;</h:panelGroup>
                        <c:forEach items="#{timeViewBean.currentWeek}" var="time">
                            <h:panelGroup>
                                <h:panelGroup rendered="#{timeViewBean.isCurrentTime(time) and not empty timeViewBean.currentTime}">
                                    <h:graphicImage name="images/play-icon.png" rendered="#{timeViewBean.currentTime.running}"/>
                                    <h:graphicImage name="images/pause-icon.png" rendered="#{not timeViewBean.currentTime.running and empty timeViewBean.currentTime.stopTime}"/>
                                    <h:graphicImage name="images/stop-icon.png" rendered="#{not empty timeViewBean.currentTime.stopTime}"/>
                                </h:panelGroup>
                            </h:panelGroup>
                        </c:forEach>
                    </h:panelGrid>
                    <h:panelGroup id="weekTotalTime" layout="block" styleClass="weekTotal">
                        #{localizer.localized('WEEK_TOTAL')}: <h:outputLabel value="#{timeViewBean.weekTotalTime}" converter="totalTime"/>
                    </h:panelGroup>
                </h:panelGroup>
                <t:refresher id="timeTableRefresher" render="timeTable messages buttonsPanel" interval="30000"/>
            </ui:decorate>
        </ui:decorate>
        <ui:include src="jsPanel.xhtml"/>
    </ui:define>
</ui:composition>

</html>